<template>
  <ea-dialog
    v-bind="$attrs"
    v-on="$listeners"
    width="600px"
    ref="elDialog"
    class="dialog"
    :title="title"
    :type="type"
    @submit="submit"
    @reset="$refs.form.resetFields()"
    @closed="end"
  >
    <el-scrollbar wrap-class="scroll-wrap-y">
      <el-form
        ref="form"
        :rules="rules"
        :model="singleData"
        label-width="100px"
      >
        <el-form-item prop="quebankname" label="题库名称">
          <el-input
            v-model="singleData.quebankname"
            placeholder="请输入题库名称"
          ></el-input>
        </el-form-item>
        <el-form-item prop="subids" label="包含科目">
          <el-select
            v-model="singleData.subids"
            clearable
            multiple
            placeholder="请选择科目"
          >
            <el-option
              v-for="item in subjects"
              :key="item.value"
              :label="item.name"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="description" label="题库描述">
          <el-input
            v-model="singleData.description"
            placeholder="请输入题库描述"
          ></el-input>
        </el-form-item>
      </el-form>
    </el-scrollbar>
  </ea-dialog>
</template>

<script>
import editAndAdd from "@/mixins/business/editAndAdd";
export default {
  name: "EaQueBank",
  mixins: [editAndAdd],
  data() {
    return {
      moduleName: "题库",
      singleData: {
        description: "",
        quebankid: 0,
        quebankname: "",
        subids: []
      },
      subjects: [],
      rules: {
        quebankname: { required: true, message: "请输入题库名称！" },
        subids: { required: true, message: "请选择包含科目！" }
      }
    };
  },
  created() {
    this.api.getSubjects.apply(this);
  },
  methods: {
    handle() {
      if (this.type === "add") this.singleData.quebankid = null;
      return this.axios.post("/sys/queBank/addOrUpdate", this.singleData);
    }
  }
};
</script>

<style scoped></style>
